﻿using System;
using System.Collections.Generic;

namespace AspNetCoreMini
{
    public interface IFeatureCollection : IDictionary<Type, object> { }

    public static partial class Extensions
    {
        public static T Get<T>(this IFeatureCollection features)
        {
            return features.TryGetValue(typeof(T), out var value) ? (T)value : default(T);
        }
        public static IFeatureCollection Set<T>(this IFeatureCollection features, T feature)
        {
            features[typeof(T)] = feature;
            return features;
        }
    }
}